package com.xw.screen.capture.controller;

import com.xw.screen.capture.service.ScreenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：xiongwei
 * @date ：Created in 2020/11/21 23:54
 */
@Slf4j
@RestController
@RequestMapping("screen")
@Api(value = "屏幕操作", tags = "屏幕操作相关API")
public class ScreenController {

    @Autowired
    private ScreenService screenService;

    @GetMapping("/start")
    @ApiOperation(value = "开始", notes = "启动")
    public String start() {
        try {
            screenService.start();
        } catch (Exception e) {
            log.error("start错误",e);
            return e.getMessage();
        }
        return "ok";
    }

    @GetMapping("/startOnce")
    @ApiOperation(value = "开始一次", notes = "启动一次")
    public String startOnce() {
        try {
            screenService.startOnce();
        } catch (Exception e) {
            log.error("start错误",e);
            return e.getMessage();
        }
        return "ok";
    }

    @GetMapping("/stop")
    @ApiOperation(value = "停止", notes = "结束")
    public String stop() {
        try {
            screenService.stop();
        } catch (Exception e) {
            log.error("stop错误",e);
            return e.getMessage();
        }
        return "ok";
    }

}
